<?php

namespace App\Http\Validate\Common;

use App\Http\Validate\AbstractBaseValidate;
use App\Models\Kms\Album\AlbumResourceModel;
use App\Service\Common\PreviewService;
use Illuminate\Support\MessageBag;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class PreviewValidate extends AbstractBaseValidate
{
    function getRules(): array
    {
        // TODO: Implement getRules() method.
        return [];
    }

    function getAttributes(): array
    {
        // TODO: Implement getAttributes() method.
        return [];
    }

    function registerValidateRules(): void
    {
        // TODO: Implement registerValidateRules() method.
    }

    function getMessages(): array
    {
        // TODO: Implement getMessages() method.
        return [];
    }

    /**
     * @param array $params
     * @return MessageBag|object
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public static function resourceListsValidate(array $params)
    {
        return self::getInstance()->validate(
            ["type", "resourceIds"],
            $params,
            [
                "type"          => self::intInValidateBuild(true, PreviewService::RESOURCE_SOURCE_TEXT),
                "resourceIds"   => 'exclude_unless:type,' . PreviewService::RESOURCE_SOURCE_1 . "|required|array|min:1|max:9",
                "resourceIds.*" => [
                    "int",
                    Rule::exists((new AlbumResourceModel())->getTable(), "id")
                ],
            ]
        );
    }


}
